import requests
from config import url, headers_web


class CourseResources:
    def __init__(self):
        self.url = url
        self.headers = headers_web

    @classmethod
    def post_del_course_info(cls, url: str, headers=headers_web, params=None, json=None, parmspath=None):
        """
        @Summary:删除课程接口
        @Description:.云课堂老师端-课程管理删除课程；2.云课堂管理端-删除课程
        :param url:
        :param headers:
        :param params:validCode:id=?&signKey=123123(md5加密)
        :param json:None
        :param parmspath:id:课程id
        :return:操作成功
        """
        url = url + f"/courseApi/v1/course/{parmspath}/delete"
        r = requests.post(url=url, headers=headers, params=params, json=json)
        return r

    @classmethod
    def getCourseResourcePage(cls, url: str, headers=headers_web, params=None):
        """
        @Summary:getCourseResourcePage
        @Description:查询课程信息
        :param url:
        :param headers:
        :param params:
        :return:操作成功
        """
        url = url + "/courseApi/v1/courseResources"
        r = requests.get(url=url, headers=headers, params=params)
        return r

    @classmethod
    def get_course_del_status(cls, url: str, headers, params):
        """
        @Summary:查询基础课程删除状态
        @Description:云课堂老师端——课程首页
        :param url:
        :param headers:
        :param params:{
                        "courseId":"", # 课程id
                        "validCode":"" # 验证码：courseId={xxx}&signKey=123123(md5加密)
                        }
        :return: boolean
        """
        url = url + "/courseApi/v1/coursedeletestate"

        r = requests.get(url=url, headers=headers, params=params)

        return r
